package cn.edu.suda.catalina.dataupdate.service.implement;

import cn.edu.suda.catalina.dataupdate.entity.Users;
import cn.edu.suda.catalina.dataupdate.service.UsersService;
import cn.edu.suda.catalina.dataupdate.domain.UsersRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author admin
 * @date 2017/5/23
 */
@Service
public class UsersServiceImpl implements UsersService {
    @Autowired
    private UsersRepository userRepository;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    @Transactional
    public Users save(Users user) {
        return userRepository.save(user);
    }

    @Override
    public void add(String key, Users user) {
        userRepository.add(stringRedisTemplate, key, user);
    }

    @Override
    public Users getUserByKey(String key) {
        return userRepository.getUserByKey(stringRedisTemplate, key);
    }
}
